package com.zxy.javaproject.service;

import bean.HotVideo;
import bean.HotVideoCommon;
import com.alibaba.fastjson.JSONObject;
import com.zxy.javaproject.Constants;
import com.zxy.javaproject.net.HttpUtils;

import java.util.List;

/**
 * @author: zhangyuyuan
 * @email: 1240205971@qq.com
 * @phone: 13080167977
 * @desc:
 * @DateTime: 2021/12/23 21:17
 **/
public class HotVideoService {
    /**
     * 该方法用于获取热门数据，并将热门数据返回
     * @return
     */

    public List<HotVideo> getHotVideo(){
        String url = Constants.TRIP_URL
                + "?key=" + Constants.TRIP_KEY
                + "&type=hot_video"
                + "&size=20";
        //调取网络请求
        String result = HttpUtils.get(url);
        System.out.println(result);




        //Json解析
        HotVideoCommon videoCommon = JSONObject.parseObject(result, HotVideoCommon.class);

        System.out.println(videoCommon.result.size());
        return videoCommon.result;

    }
}
